Skip to content

fix: remove stale fee snapshot from BotFactory and reduce minFeePadding to 10x#21464

Draft
AztecBot wants to merge 1 commit intonextfrom
claudebox/fix-bot-test-fee-padding
Draft

fix: remove stale fee snapshot from BotFactory and reduce minFeePadding to 10x#21464
AztecBot wants to merge 1 commit intonextfrom
claudebox/fix-bot-test-fee-padding

Conversation

@AztecBot
Copy link
Collaborator

Summary

Fixes the flaky e2e_bot test ("does not reuse prior bridge claims if recipient address changes") by addressing the root cause instead of increasing fee padding.

Root cause: BotFactory.setupAccountWithPrivateKey() was snapshotting maxFeesPerGas once at setup time (factory.ts:225), then baking it into gasSettings. By the time the sequencer processed the tx (many blocks later), anvil's L1 baseFee had escalated due to rapid block building, causing gasFees.feePerL2Gas > maxFeesPerGas.feePerL2Gas.

Fix:

  • Remove the explicit maxFeesPerGas snapshot from setupAccountWithPrivateKey
  • Let the wallet's completeFeeOptions() estimate fees at send() time using the configured minFeePadding (already set in the constructor via PR fix: set wallet minFeePadding in BotFactory constructor #20992)
  • Reduce minFeePadding from 99 (100x) back to 9 (10x) in bridge resume tests — now sufficient since fees are estimated moments before sending

Related: A-648

Context

ClaudeBox log: https://claudebox.work/s/c64a6207b95c4a16?run=4

…ng to 10x

The BotFactory was snapshotting maxFeesPerGas once during account setup,
then using that stale value for the deployment tx. By the time the tx was
processed, L1 baseFee had escalated (due to rapid block building on anvil),
causing the tx to be rejected.

Instead of snapshotting fees, let the wallet re-estimate at send() time
via completeFeeOptions(), which uses the configured minFeePadding. This
makes the fee estimate fresh and a 10x padding sufficient.

Changes:
- Remove explicit maxFeesPerGas snapshot from setupAccountWithPrivateKey
- Let wallet.completeFeeOptions() estimate fees at send time
- Reduce minFeePadding from 99 (100x) back to 9 (10x) in bridge resume tests
@AztecBot AztecBot added the claudebox Owned by claudebox. it can push to this PR. label Mar 13, 2026
ludamad added a commit that referenced this pull request Mar 13, 2026
 #20992 #21148) (#21465)

## Summary

Backports three fixes from `next` and adds a fourth to stabilize the
flaky `e2e_bot` test on `v4-next`.

**Root cause:** The `BotFactory` was snapshotting `maxFeesPerGas` once
during account setup, then using that stale value for subsequent
transactions. L1 baseFee escalation on anvil (from rapid block building)
caused fees to exceed the stale cap.

### Changes

1. **BotFactory constructor sets wallet fee padding** (backport of
#20992)
- Calls `wallet.setMinFeePadding(config.minFeePadding)` so all setup
transactions use the configured padding instead of the wallet default
(0.5x)

2. **GasFees.mul() precision fix** (backport of #20962)
   - Uses bigint arithmetic for integer scalars to avoid precision loss
- Uses `Math.ceil` for non-integer scalars to ensure fees always round
up

3. **Dedicated L1 account for bridge resume tests** (backport of #21148)
- Uses private key index 7 instead of the default mnemonic (shared with
the sequencer)
   - Avoids nonce races on approve/deposit calls in `bridgeL1FeeJuice`
- Uses `getPrivateKey()` helper with auto-incrementing index for other
tests

4. **Remove stale fee snapshot** (new, also in #21464 on `next`)
- Removes explicit `maxFeesPerGas` snapshot from
`setupAccountWithPrivateKey`
- Lets the wallet re-estimate fees at `send()` time via
`completeFeeOptions()`
- Fresh estimation + 10x padding is sufficient since fee change within 1
block is minimal

Related: A-648, #21453

ClaudeBox log: https://claudebox.work/s/c64a6207b95c4a16?run=4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

claudebox Owned by claudebox. it can push to this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant